package com.aidong.activity.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.json.annotations.JSON;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;

import com.aidong.activity.biz.MstCampaignBiz;
import com.aidong.activity.entity.Home;
import com.aidong.activity.entity.Member;
import com.aidong.activity.entity.MstCampaign;
import com.aidong.jobs.async.SmsTask;
import com.aidong.jobs.constants.JobConst;
import com.aidong.myprofile.biz.MyAddressBiz;
import com.aidong.pay.biz.OrdergeneratedBiz;
import com.aidong.stadium.biz.MstStoreBiz;
import com.aidong.util.CountDistance;
import com.aidong.util.PageUtil;
import com.aidong.util.RandomUtil;
import com.aidong.util.ReadPropertiesUtil;
import com.aidong.util.bus.CodeConsts;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 活动action
 * 
 * @author java
 * @version 1.0 2015.6.25
 */
@ParentPackage("json")
@Namespace("/")
public class MstCampaignAction implements ModelDriven<MstCampaign> {
	private MstCampaign campaign; // 活动实体类

	@Override
	public MstCampaign getModel() {
		if (campaign == null) {
			campaign = new MstCampaign();
		}
		return campaign;
	}

	@Autowired
	private MyAddressBiz myAddressBiz;
	@Autowired
	private MstCampaignBiz mstCampaignBiz; // 活动service
	@Autowired
	private OrdergeneratedBiz ordergeneratedBiz; // 活动订单service
	@Autowired
	private MstStoreBiz mstStoreBiz;
	@Autowired
	private SmsTask smsTask;

	private Map<String, Object> map; // 返回的json数据

	@JSON
	public Map<String, Object> getMap() {
		return map;
	}

	private int pageCurrent; // 当前页 工具属性 用来分页

	/**
	 * 当前页 工具属性 用来分页
	 * 
	 * @param pageCurrent
	 */
	public void setPageCurrent(int pageCurrent) {
		this.pageCurrent = pageCurrent;
	}
	
	
	/**
	 * 获得未下架的活动
	 * 
	 * @return
	 */
	@Action(value = "getmstcampaign", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCampaign() {
		map = new HashMap<String, Object>();
		Map<String, Object> pageMap = PageUtil.page(20, campaign.getPageCurrent());
		map.put("pageCurrent", pageMap.get("pageCurrent")); // 当前页
		pageMap.put("cityId", campaign.getCityId());
		pageMap.put("type", campaign.getPriceType());
		List<Map<String, Object>> campaigns = mstCampaignBiz.getMstCampaign(pageMap);
		if (campaigns.size() > 0) {
			for (Map<String, Object> campaign : campaigns) {
				String heat = campaign.get("heat") + "";
				if (heat.equals("null")) {
					campaign.put("heat", 0);
				}
				campaign.put("bigUrl", ReadPropertiesUtil.getIMGREAD(campaign.get("bigUrl") + ""));
				String stratDate = campaign.get("stratDate").toString(); // 活动开始日期
				// 新版活动没有周只有日期和时间
				String stratTime = campaign.get("stratTime").toString(); // 活动开始时间
				String week = campaign.get("week").toString(); // 周
				campaign.put("campaignStartTime", stratDate + "(" + week + ")" + stratTime); // 活动开始时间(前端显示)

				int dayCount = mstCampaignBiz.getMstCampaignDay(stratDate);
				campaign.put("dayCount", dayCount);

				// campaign.remove("stratDate");
				// campaign.remove("stratTime");
				campaign.remove("week");
			}
			// 餐饮入口
			Map<String, Object> foodEntry = mstCampaignBiz.getFoodEntryImage();
			foodEntry.put("picUrl", ReadPropertiesUtil.getIMGREAD(foodEntry.get("picUrl") + ""));
			map.put("code", 1);
			map.put("foodEntry", foodEntry);
			map.put("result", campaigns);
			return "succ";
		} else {
			map.put("code", 1);
			JSONArray jsonArray = new JSONArray();
			map.put("result", jsonArray);// 活动列表为空
			return "succ";
		}
	}

	/**
	 * 活动详情介绍 activeStatus(活动状态) 1、尚未报名 2、正在报名 3、报名结束 4、活动进行中 5、活动结束 6、人数已满
	 * 7、已报名
	 * 
	 * @return
	 */
	@Action(value = "getmstcampaigndetail", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCampaignDetail() {
		map = new HashMap<String, Object>();
		try {
			int campaignId = campaign.getCampaignId(); // 活动ID
			String idongId = campaign.getIdongId();
			if (campaignId > 0) {
				// 活动介绍
				Map<String, Object> duceMap = mstCampaignBiz.getCampaignIntroduce(campaignId);
				duceMap.put("middleUrl", ReadPropertiesUtil.getIMGREAD(duceMap.get("middleUrl") + ""));
				duceMap.put("smallUrl", ReadPropertiesUtil.getIMGREAD(duceMap.get("smallUrl") + ""));
				String stratDate = duceMap.get("stratDate").toString(); // 活动开始日期
				String stratTime = duceMap.get("stratTime").toString(); // 活动开始时间
				String week = duceMap.get("week").toString(); // 周
				duceMap.put("campaignStartTime", stratDate + "(" + week + ")" + stratTime); // 活动开始时间(前端显示)
				duceMap.put("lookMore", duceMap.get("detailUrl"));

				// duceMap.remove("stratDate");
				// duceMap.remove("stratTime");
				duceMap.remove("week");
				int movieFlg = Integer.valueOf(duceMap.get("movieFlg").toString());

				if (!"".equals(idongId) && idongId != null) {
					// 判断是否对该活动已点赞
					Map<String, Object> praiseMap = new HashMap<String, Object>();
					praiseMap.put("idongId", idongId);
					praiseMap.put("campaignId", campaignId);
					int praiseFlag = mstCampaignBiz.getIfCampaignPrasie(praiseMap);
					if (praiseFlag > 0) {
						duceMap.put("praiseStatus", 1); // 已点赞
					} else {
						duceMap.put("praiseStatus", 0); // 未点赞
					}

					if (movieFlg != 3) {
						// 判断是否已报名
						Map<String, Object> paraMap = new HashMap<String, Object>();
						paraMap.put("campaignId", campaignId);
						paraMap.put("idongId", idongId);
						List<Map<String, Object>> alreayMap = mstCampaignBiz.getIfAlreadyReg(paraMap);
						if (alreayMap.size() > 0) {
							for (Map<String, Object> alreay : alreayMap) {
								int alreayStatus = Integer.parseInt(alreay.get("status").toString());
								int orderStatus=Integer.parseInt(alreay.get("ostatus").toString());//订单状态
								int processId=Integer.parseInt(alreay.get("processId").toString());//订单流程
								
								if(alreayStatus == CodeConsts.CODE_STATIC_BOOKING_BOOKING){
									if(orderStatus==1 && processId==2){
										duceMap.put("activeStatus", 7); // 已报名
										duceMap.put("activeValue", 7); // 已报名
									}else{
										duceMap.put("activeValue", 8); // 待支付
										duceMap.put("activeStatus", 7); // 已报名
										int orderId=Integer.parseInt(alreay.get("orderId").toString());
										int subscribeId=Integer.parseInt(alreay.get("subscribeId").toString());
										map.put("orderId", orderId);
										map.put("subscribeId", subscribeId);
										map.put("userName", alreay.get("userName").toString());
										map.put("phone", alreay.get("phone").toString());
										List<Map<String, Object>> payInfo = getPayInfo(
												mstCampaignBiz.getPayInfo(campaignId));
										map.put("zhifubao", payInfo.get(0).get("zhifubao"));
										map.put("weixin", payInfo.get(1).get("weixin"));
										map.put("voucher", payInfo.get(2).get("voucher"));
										map.put("exchange", payInfo.get(3).get("exchange"));
										map.put("membership", payInfo.get(4).get("membership"));
										map.put("discount", payInfo.get(5).get("discount"));
									}
									break;
								}
							}
						}
					}

				} else {
					duceMap.put("praiseStatus", 0); // 未点赞
				}

				// 活动已报名人数
				int signPersonCount = mstCampaignBiz
						.getCampaignValidCount(Integer.parseInt(duceMap.get("campaignId").toString()));
				duceMap.put("signPersonCount", signPersonCount);
				if (movieFlg != 3) {
					// 活动可报名人数
					int allowPerson = Integer.parseInt(duceMap.get("allowPerson").toString());
					int values=Integer.parseInt(duceMap.get("activeValue").toString());
					int stat=Integer.parseInt(duceMap.get("activeStatus").toString());
					if (signPersonCount >= allowPerson &&  values!=7 && values!=8 && stat!=7) {
						duceMap.put("activeStatus", 6); // 人数已满
						duceMap.put("activeValue", 6);
						// 为了显示的正确，将报名人数和允许人数修改一致？？？需要吗
					}
				}

				// 已报名人数列表
				List<Map<String, Object>> applyPerson = mstCampaignBiz.getMstCampaignDetail(campaignId);
				if (applyPerson.size() > 0) {
					for (Map<String, Object> map : applyPerson) {
						if (map != null) {
							map.put("headUrl", ReadPropertiesUtil.getIMGREAD(map.get("headUrl") + ""));
						}
					}
				}

				Map<String, Object> resultMap = new HashMap<String, Object>();
				resultMap.put("campaignDuce", duceMap);
				resultMap.put("applyPerson", applyPerson);

				if (movieFlg == 3) { // 票务
					if (duceMap.get("pickUpWay").toString().contains("3")) {// 虚拟码
						// 查询电影券是都已售完
						int movieCount = mstCampaignBiz.ifHasMoviceTickets(campaignId);
						if (movieCount == 0) {
							resultMap.put("buyFlag", 2);// 1-可购买 2-已售完
						} else {
							resultMap.put("buyFlag", 1);// 1-可购买 2-已售完
						}
					} else {
						resultMap.put("buyFlag", 1);
					}
				}
				map.put("code", 1);
				map.put("result", resultMap);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 获得活动回顾列表
	 * 
	 * @return
	 */
	@Action(value = "getmstcampaignreview", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCampaignReview() {
		map = new HashMap<String, Object>();
		try {
			Map<String, Object> pageMap = PageUtil.page(20, campaign.getPageCurrent());
			pageMap.put("cityId", campaign.getCityId());
			List<Map<String, Object>> campaigns = mstCampaignBiz.getEndCampaign(pageMap);
			if (campaigns.size() > 0) {
				for (Map<String, Object> campaign : campaigns) {
					campaign.put("bigUrl", ReadPropertiesUtil.getIMGREAD(campaign.get("bigUrl") + ""));
					String stratDate = campaign.get("stratDate").toString(); // 活动开始日期
					String stratTime = campaign.get("stratTime").toString(); // 活动开始时间
					String week = campaign.get("week").toString(); // 周
					campaign.put("campaignStartTime", stratDate + "(" + week + ")" + stratTime); // 活动开始时间(前端显示)

					// campaign.remove("stratDate");
					// campaign.remove("stratTime");
					campaign.remove("week");
				}
			}
			map.put("code", 1);
			map.put("pageCurrent", pageMap.get("pageCurrent")); // 当前页
			map.put("result", campaigns);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 回顾照片详情
	 * 
	 * @return
	 */
	@Action(value = "getmstreviewduce", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMstCampaignReviewDuce() {
		map = new HashMap<String, Object>();
		try {
			int campaignId = campaign.getCampaignId(); // 活动ID
			if (campaignId > 0) {
				Map<String, Object> duces = mstCampaignBiz.getMstCampaignReviewDuce(campaignId);
				duces.put("middleUrl", ReadPropertiesUtil.getIMGREAD(duces.get("middleUrl") + ""));
				List<Map<String, Object>> reviews = mstCampaignBiz.getCampaignReview(campaignId);
				if (reviews.size() > 0) {
					for (Map<String, Object> review : reviews) {
						review.put("picUrl", ReadPropertiesUtil.getIMGREAD(review.get("picUrl") + ""));
					}
				}
				Map<String, Object> resultMap = new HashMap<String, Object>();
				resultMap.put("duces", duces);
				resultMap.put("photo", reviews);

				map.put("code", 1);
				map.put("result", resultMap);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 如果报名之前已登陆 查找已注册信息
	 * 
	 * @return
	 */
	@Action(value = "getmemberreg", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getMemberReg() {
		map = new HashMap<String, Object>();
		try {
			String idongId = campaign.getIdongId(); // 爱动号
			if (!"".equals(idongId) && idongId != null) {
				Map<String, Object> resultMap = mstCampaignBiz.getMemberReg(Integer.parseInt(idongId));

				if ("".equals(resultMap.get("contactPhone")) || resultMap.get("contactPhone") == null) {
					resultMap.put("contactPhone", "");
				}

				if ("".equals(resultMap.get("contactName")) || resultMap.get("contactName") == null) {
					resultMap.put("contactName", "");
				}

				map.put("code", 1);
				map.put("result", resultMap);
				return "succ";

			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 报名、预约 获得手机验证码(独立接口)
	 * 
	 * @return
	 */
	@Action(value = "getphoneautocode", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getPhoneAutoCode() {
		map = new HashMap<String, Object>();
		try {
			String phoneNo = campaign.getContactPhone(); // 报名联系电话
			String codes=campaign.getCode();
			if(StringUtils.isBlank(codes)){
				map.put("code", 0);
				map.put("msg", "请下载最新版本");
				return "succ";
			}
			
			String[] codeMap=JobConst.codeMap.get(phoneNo);
			
			if(codeMap==null){
				map.put("code", 0);
				map.put("msg", "验证码已过期");
				return "succ";
			}
			if (!"".equals(phoneNo) && phoneNo != null ) {
				if(!codes.equalsIgnoreCase(codeMap[0])){
					map.put("code", 0);
					map.put("msg", "验证码输入有误");
					return "succ";
				}
				JobConst.codeMap.remove(phoneNo);
				String captcha = RandomUtil.randomNumber(6);
				int code=Integer.parseInt(captcha);
				smsTask.captcha(phoneNo,String.valueOf(code));
				map.put("code", 1);
				map.put("result", code);
				return "succ";
			}else{
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 添加活动报名
	 * 
	 * @return
	 */
	
	@Action(value = "addactivityreg", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String addActivityReg() {
		map = new HashMap<String, Object>();
		map=mstCampaignBiz.editCampaignDetail(campaign);
		return "succ";
	}

	/**
	 * 活动报名列表
	 * 
	 * @return
	 */
	@Action(value = "getalreadysignedperson", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getAlreadySignedPerson() {
		map = new HashMap<String, Object>();
		try {
			int campaignId = campaign.getCampaignId(); // 活动Id
			String coordinate = campaign.getCoordinate(); // 请求经纬度
			String idongId = campaign.getIdongId(); // 爱动号
			if (campaignId > 0) {
				List<Member> members = mstCampaignBiz.getAlreadySignedPerson(campaignId);
				if (members.size() > 0) {
					for (Member member : members) {
						member.setHeadUrl(ReadPropertiesUtil.getIMGREAD(member.getHeadUrl() + ""));
						double lon = member.getLon();
						double lat = member.getLat();
						if ((!"".equals(coordinate) && coordinate != null) && lon > 0 && lat > 0) {
							String[] reqNate = coordinate.split(",");
							int dis = 0; // 距离
							if (reqNate.length > 0) {
								double discance = CountDistance.distance(Double.parseDouble(reqNate[0]),
										Double.parseDouble(reqNate[1]), lon, lat);
								dis = (int) Math.rint(discance); // 四舍五入取整数
							}
							int distance = dis / 1000;
							if (distance < 1) {
								if (dis <= 100) {
									member.setCoordinate("<100m"); // 相距距离
								} else if (100 < dis && dis <= 500) {
									member.setCoordinate("<500m"); // 相距距离
								} else if (500 < dis && dis <= 800) {
									member.setCoordinate("<800m"); // 相距距离
								} else {
									member.setCoordinate(dis + " m"); // 相距距离
								}
							} else {
								member.setCoordinate(distance + " km"); // 相距距离
							}
						}
						Map<String, Object> paraMap = new HashMap<String, Object>();
						paraMap.put("idongId", idongId); // 关注人
						paraMap.put("tionIdongId", member.getIdongId()); // 被关注人
						int attionCount = mstCampaignBiz.getIfAttention(paraMap);
						if (!"".equals(idongId) && idongId != null) {
							if (attionCount > 0) { // 已关注
								member.setAttionStatus("1");
							} else { // 关注
								member.setAttionStatus("2");
							}
						} else { // 关注
							member.setAttionStatus("2");
						}
					}
				} else {
					map.put("code", 0);
					map.put("msg", "暂时没有人参加报名");
					return "succ";
				}
				map.put("code", 1);
				map.put("result", members);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 内容推荐
	 * 
	 * @return
	 */
	@Action(value = "getcampaignbanner", results = {
			@Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getCampaignBanner() {
		map = new HashMap<String, Object>();
		try {
			String recmdSite = campaign.getRecmdSite(); // 请求位置 1、activitySite
														// 2、foodSite
														// 3、adPosition
														// 5、circlePosition
			if (!"".equals(recmdSite) && recmdSite != null) {
				// List<Map<String, Object>> recommends = new
				// ArrayList<Map<String, Object>>();
				List<Home> listHome = new ArrayList<Home>();
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("recmdSite", recmdSite);
				if (recmdSite.equals("shoppRecommend")) {
					Map<String, Object> pageMap = PageUtil.page(6, campaign.getPageCurrent());
					pageMap.put("recmdSite", recmdSite);
					pageMap.put("cityId", campaign.getCityId());
					listHome = mstCampaignBiz.getCampaignBanner(pageMap);
				} else {
					paraMap.put("cityId", campaign.getCityId());
					listHome = mstCampaignBiz.getCampaignBanner(paraMap);
				}

				for (Home home : listHome) {
					home.setRecmdSite(recmdSite);
				}
				map.put("code", 1);
				map.put("result", listHome);
				return "succ";
			} else {
				map.put("code", 0);
				map.put("msg", "参数缺失");
				return "succ";
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	/**
	 * 内容推荐
	 * 
	 * @return
	 */
	@Action(value = "matchchoosestore", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String matchChooseStore() {
		map = new HashMap<String, Object>();
		int campaignId = campaign.getCampaignId(); // 活动Id
		// 城市列表
		List<Map<String, Object>> citys = mstStoreBiz.getMstCity("");

		// 行政区域列表
		List<Map<String, Object>> regions = new ArrayList<Map<String, Object>>();

		// 行政区域结果列表
		List<Map<String, Object>> regionsResult = new ArrayList<Map<String, Object>>();

		try {
			for (Map<String, Object> city : citys) {
				// 区列表
				List<Map<String, Object>> regionList = mstStoreBiz.getMstRegion(city.get("areaId").toString());
				// 查询该门店可取票区
				List<Map<String, Object>> districtsCamp = mstCampaignBiz.getEventAreas(campaignId);

				for (Map<String, Object> region : regionList) {
					int flag = 0;
					for (int jj = 0; jj < districtsCamp.size(); jj++) {
						if (region.get("areaId").equals(districtsCamp.get(jj).get("areaId"))) {
							flag = 1;
							break;
						}
					}
					if (flag == 1) {
						regionsResult.add(region);
					}
				}
				for (Map<String, Object> region : regionsResult) {
					List<Map<String, Object>> districts = new ArrayList<Map<String, Object>>();

					// 获取可取票 某区的商圈列表
					Map<String, Object> paraMap = new HashMap<String, Object>();
					paraMap.put("areaId", region.get("areaId").toString());
					paraMap.put("campaignId", campaignId);
					List<Map<String, Object>> storesMap = mstCampaignBiz.getEventAreaStore(paraMap);
					for (int k = 0; k < storesMap.size(); k++) {
						if (region.get("areaId").toString().equals(storesMap.get(k).get("areaId"))) {
							districts.add(storesMap.get(k));
						}
					}
					region.put("district", districts);
				}

				for (int i = 0; i < regionsResult.size(); i++) {
					regions.add(regionsResult.get(i));
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		map.put("result", regions);
		return "succ";
	}

	@Action(value = "getopencity", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getOpenCity() {
		map = new HashMap<String, Object>();
		try {
			List<Map<String, Object>> cityInfoMap = mstCampaignBiz.getOpenCity();
			map.put("code", 1);
			map.put("result", cityInfoMap);
			return "succ";
		} catch (Exception e) {
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}
	
	@Action(value = "getLuckyDraw", results = { @Result(name = "succ", type = "json", params = { "root", "map" }) })
	public String getLuckyDraw() {
		map = new HashMap<String, Object>();
		try {
			Map<String,Object> resultMap=new HashMap<String,Object>();
			resultMap.put("first",null);
			resultMap.put("second",null);
			resultMap.put("third",null);
			long time=System.currentTimeMillis();
			List<Map<String,Object>> timeMap=mstCampaignBiz.getLuckyDrawTime();
			for(int i=0;i<timeMap.size();i++){
				Map<String,Object> mapt = new HashMap<String, Object>();
				mapt.put("type", i+1);
				List<Map<String,Object>> reMap=mstCampaignBiz.getLuckyDrawPersonList(mapt);
				if(i==0){
					resultMap.put("first", reMap);
				}else if(i==1){
					resultMap.put("second", reMap);
				}else if(i==2){
					resultMap.put("third", reMap);
				}
				
				
				if(i+1 < timeMap.size())
					timeMap.get(i).put("isTrue", reMap.size()>=2 || ((time/1000) >=Integer.parseInt(timeMap.get(i).get("beginTime").toString()) && (time/1000) > Integer.parseInt(timeMap.get(i+1).get("beginTime").toString()))?0:1);
				else
					timeMap.get(i).put("isTrue", reMap.size()>=2 ?0:1);
			}
			map.put("code", 1);
			map.put("result", resultMap);
			map.put("time", timeMap);
			map.put("serverTime",time);
			return "succ";
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("msg", "系统异常");
			return "succ";
		}
	}

	//得到支付信息
	public List<Map<String, Object>> getPayInfo(String payInfo) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		Map<String, Object> zhifubao = new HashMap<String, Object>();
		Map<String, Object> weixin = new HashMap<String, Object>();
		Map<String, Object> voucher = new HashMap<String, Object>();
		Map<String, Object> exchange = new HashMap<String, Object>();
		Map<String, Object> membership = new HashMap<String, Object>();
		Map<String, Object> discount = new HashMap<String, Object>();
		if (payInfo.contains("1")) {
			zhifubao.put("zhifubao", true);
			result.add(zhifubao);
		} else {
			zhifubao.put("zhifubao", false);
			result.add(zhifubao);
		}
		if (payInfo.contains("2")) {
			weixin.put("weixin", true);
			result.add(weixin);
		} else {
			weixin.put("weixin", false);
			result.add(weixin);
		}
		if (payInfo.contains("3")) {
			voucher.put("voucher", true);
			result.add(voucher);
		} else {
			voucher.put("voucher", false);
			result.add(voucher);
		}
		if (payInfo.contains("4")) {
			exchange.put("exchange", true);
			result.add(exchange);
		} else {
			exchange.put("exchange", false);
			result.add(exchange);
		}
		if (payInfo.contains("5")) {
			membership.put("membership", true);
			result.add(membership);
		} else {
			membership.put("membership", false);
			result.add(membership);
		}
		if (payInfo.contains("6")) {
			discount.put("discount", true);
			result.add(discount);
		} else {
			discount.put("discount", false);
			result.add(discount);
		}
		return result;
	}

}